package com.wwz.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wwz.mapper.PersonMapper;
import com.wwz.pojo.Person;
import com.wwz.pojo.query.PersonQuery;
import com.wwz.service.PersonService;
import org.springframework.stereotype.Service;

/**
* @author Admin
* @description 针对表【person】的数据库操作Service实现
* @createDate 2023-03-05 20:49:14
*/
@Service
public class PersonServiceImpl extends ServiceImpl<PersonMapper, Person>
    implements PersonService {

    @Override
    public IPage<Person> toPage(PersonQuery query) {
        return page(query.build(), lambdaQuery().getWrapper()
                .eq(StrUtil.isNotEmpty(query.getName()), Person::getName, query.getName())
                .orderByDesc(Person::getCreateTime));
    }
}




